<template>
  <a-modal v-model:visible.sync="store.state.user.add_status" title="角色新增" @ok="handleOk" okText="确认" cancelText="取消"
           @cancel="handle_cancel">
    <div class="row_box">
      <div class="column_box">
        <span>开始时间</span>
<!--        <a-input v-model:value="formState.params.classBeginDict" placeholder="请输入角色名称"/>-->
        <a-time-picker v-model:value="formState.params.classBeginDict" valueFormat="HH:mm:ss" placeholder="" />
      </div>
      <div class="column_box">
        <span>结束时间</span>
        <a-time-picker v-model:value="formState.params.classEndDict" valueFormat="HH:mm:ss" placeholder="" />
      </div>
      <div class="column_box">
        <span>班次</span>
        <a-select
            v-model:value="formState.params.className"
            style="width: 100%"
            ref="select"
        >
          <a-select-option value="白班">白班</a-select-option>
          <a-select-option value="晚班">晚班</a-select-option>
        </a-select>
<!--        <a-input v-model:value="formState.params.className" placeholder="请输入角色名称"/>-->
      </div>
      <div class="column_box">
        <span>首次开机容许偏差</span>
        <a-input type="number" v-model:value="formState.params.firstRun" placeholder="请输入角色编码"/>
      </div>
    </div>
  </a-modal>
</template>

<script>
import {defineComponent, reactive} from "vue";
import {useStore} from "vuex"
import {edit_classSet} from "@/api/team"
import {message} from "ant-design-vue";

export default defineComponent({
  name: "team_add",
  setup(props, context) {
    const formState = reactive({
      params: {
        "cId": 0,
        "className": "",
        "classBeginDict": "",
        "classEndDict": "",
        "firstRun": 0,
        "createTime": "",
        "updateTime": "",
        "createUserId": "",
        "updateUserId": ""
      }
    })

    /**
     * 状态管理
     *
     * */
    const store = useStore()

    /**
     * 确认新增
     *
     * */
    const handleOk = async () => {
      store.commit("SET_ADD_ROLE", false)

      const res = await edit_classSet(formState.params)
      console.log(res)
      if (res.code === 1) {
        message.success("新增成功")
        context.emit("re_flash:re_flash", "")
        return
      }
      message.success(res.message)

    }

    /**
     * 取消
     * */
    const handle_cancel = () => {
      store.commit("SET_ADD_ROLE", false)
    }

    return {
      formState,
      //状态管理
      store,
      // methods
      handleOk,
      handle_cancel
    }
  },
})
</script>

<style scoped lang="scss">

</style>
